//
//  kuangListTableViewCell.swift
//  AreaChainblock
//
//  Created by 赵佟越 on 2018/11/5.
//  Copyright © 2018年 zhaotongyue. All rights reserved.
//

import UIKit

class kuangListTableViewCell: UITableViewCell {
    @IBOutlet weak var timeLabel: UILabel!
    @IBOutlet weak var mybackview: UIView!
    @IBOutlet weak var moneyLabel: UILabel!
    //    @IBOutlet weak var typeLabel: UILabel!
    private var myModel:productModel? = productModel()
    var isFrom :String!
    var model :productModel{
        set {
            myModel = newValue;
            if newValue.dke != nil{
                myModel?.dke =
                    String(format: "%.3f", Float(newValue.dke as String!)!)
            }
            
            if newValue.m != nil{
                myModel?.m =
                    String(format: "%.3f", Float(newValue.m as String!)!)
            }
            if newValue.n != nil{
                myModel?.n =
                    String(format: "%.3f", Float(newValue.n as String!)!)
            }
            
            mybackview.backgroundColor = UIColor.clear
            timeLabel.text = myModel?.create_time
            timeLabel.textAlignment = .right
            timeLabel.textColor = UIColor.white
            moneyLabel.textColor = UIColor.white
            moneyLabel.textAlignment = .right
            if isFrom == "M" {
                moneyLabel.text = String(format:"%@      -%@ cd",XALanguageManager.getString(key: ""), (myModel?.m)!)
                
                if myModel?.type == "1"{
                    let attrMStr = NSMutableAttributedString()
                    let attacmentM_baozhi = NSTextAttachment()
                    attacmentM_baozhi.image = UIImage(named: "锁@2x")
                    attacmentM_baozhi.bounds = CGRect(x: 5, y: 0, width: 12, height: 12)
                    
                    var attrMStrbaozhi : NSAttributedString = NSAttributedString(string: "")
                    attrMStrbaozhi = NSAttributedString(string: String(format:"%@      -%@ cd",XALanguageManager.getString(key: ""), (myModel?.m)!))
                    let attacmentM_baozhi2 = NSAttributedString(attachment: attacmentM_baozhi)
                   
                    attrMStr.append(attacmentM_baozhi2)
                    attrMStr.append(attrMStrbaozhi)
                    
                    moneyLabel.attributedText = attrMStr

                }
                
                
                
                
            }else if isFrom == "N"{
                moneyLabel.text = String(format:"%@     - %@ mt",XALanguageManager.getString(key: "") ,(myModel?.n)!)
                
                if myModel?.type == "1"{
                    let attrMStr = NSMutableAttributedString()
                    let attacmentM_baozhi = NSTextAttachment()
                    attacmentM_baozhi.image = UIImage(named: "锁@2x")
                    attacmentM_baozhi.bounds = CGRect(x: 5, y: 0, width: 12, height: 12)
                    
                    var attrMStrbaozhi : NSAttributedString = NSAttributedString(string: "")
                    attrMStrbaozhi = NSAttributedString(string: String(format:"%@     - %@ mt",XALanguageManager.getString(key: "") ,(myModel?.n)!))
                    let attacmentM_baozhi2 = NSAttributedString(attachment: attacmentM_baozhi)
                   attrMStr.append(attacmentM_baozhi2)
                    attrMStr.append(attrMStrbaozhi)
                    
                    moneyLabel.attributedText = attrMStr

                }
            }else{
                moneyLabel.text = String(format:"%@     + %@ dke",XALanguageManager.getString(key: ""), (myModel?.dke)!)
                if myModel?.type == "1"{
                    let attrMStr = NSMutableAttributedString()
                    let attacmentM_baozhi = NSTextAttachment()
                    attacmentM_baozhi.image = UIImage(named: "锁@2x")
                    attacmentM_baozhi.bounds = CGRect(x: 5, y: 0, width: 12, height: 12)
                    
                    var attrMStrbaozhi : NSAttributedString = NSAttributedString(string: "")
                    attrMStrbaozhi = NSAttributedString(string: String(format:"%@     + %@ dke",XALanguageManager.getString(key: ""), (myModel?.dke)!))
                    let attacmentM_baozhi2 = NSAttributedString(attachment: attacmentM_baozhi)
                   
                    attrMStr.append(attacmentM_baozhi2)
                    attrMStr.append(attrMStrbaozhi)
                    
                    moneyLabel.attributedText = attrMStr
                }
            }
        }get
    {
    return (self.myModel)!
    
    }
}

override func awakeFromNib() {
    super.awakeFromNib()
    self.contentView.backgroundColor = UIColor.clear
    // Initialization code
}

override func setSelected(_ selected: Bool, animated: Bool) {
    super.setSelected(selected, animated: animated)
    
    // Configure the view for the selected state
}



}
